package view;

import java.awt.Graphics2D;
import java.awt.event.MouseEvent;

import model.GameConfiguration;
import model.PlayerType;
import model.Slot;

public abstract class BoardState {
	protected GameConfiguration configuration;
	protected Board board;
	protected Slot[][] slots;
	private String p1, p2;
	private int lastPlayedRow, lastPlayedCol;

	protected BoardState(GameConfiguration config, Board board, Slot[][] slots,
			String p1, String p2, int lastPlayedRow, int lastPlayedCol) {
		this.configuration = config;
		this.board = board;
		this.slots = slots;
		this.p1 = p1;
		this.p2 = p2;
		this.lastPlayedCol = lastPlayedCol;
		this.lastPlayedRow = lastPlayedRow;
	}

	/**
	 * Consente di rappresentare la parte grafica del gioco
	 * 
	 * @param g2D
	 *            Oggetto utilizzato per la rappresentazione su un determinato
	 *            elemento
	 */
	protected void paintGame(Graphics2D g2D) {
		// Disegno area di gioco
		GraphicsUtils.paintGameBoard(g2D, configuration.getRows(), configuration.getCols(), slots, lastPlayedCol, lastPlayedRow);

		// Disegno le informazioni nel footer
		String textPlayer1 = p1; 
		if(configuration.getPlayer1() != PlayerType.HUMAN)
			textPlayer1 += "   Lev. " + configuration.getDepth1() + " " + configuration.getChoiceType1().toString().substring(0, 2);
		String textPlayer2 = p2;
		if(configuration.getPlayer2() != PlayerType.HUMAN)
			textPlayer2 += "   Lev. " + configuration.getDepth2() + " " + configuration.getChoiceType2().toString().substring(0, 2);
		
		GraphicsUtils.paintPlayersInfo(configuration.getRows() * GraphicsUtils.cellSize + 2
				* GraphicsUtils.gameBoardOffset + GraphicsUtils.headerHeight,
				g2D, textPlayer1, textPlayer2, configuration.getCols());

	}

	protected abstract void mousePressed(MouseEvent e);

	protected abstract void mouseMoved(MouseEvent e);

}
